package com.tobeface.wechat.message.builder;

import com.google.common.collect.Maps;
import com.tobeface.modules.lang.Requires;
import com.tobeface.wechat.message.WeChatMessageBuilder;
import com.tobeface.wechat.message.WeChatMessagePayloads;
import com.tobeface.wechat.message.WeChatMessageTypes;

import java.util.Map;

/**
 * @author loudyn
 */
public class VoiceTypedMessageBuilder extends AbstractTypedMessageBuilder {

    private String mediaId;

    /**
     * @param parent
     */
    public VoiceTypedMessageBuilder(WeChatMessageBuilder parent) {
        super(parent);
    }

    public VoiceTypedMessageBuilder mediaId(String mediaId) {
        Requires.hasText(mediaId, "mediaId must not be null or emtpy!");
        this.mediaId = mediaId;
        return this;
    }

    @Override
    protected void configPayloads(Map<String, Object> payloads) {
        Map<String, String> payload = Maps.newHashMap();
        payload.put(WeChatMessagePayloads.MEDIAID_PAYLOAD, mediaId);
        payloads.put("Voice", payload);
        payloads.put(WeChatMessagePayloads.MSGTYPE_PAYLOAD, WeChatMessageTypes.VOICE);
    }
}
